{php include wl_template('common/header');}
<style>
	.bar .button-link{
		color: #f99b00;
	}
	.timeline-block{
		border: 1px solid transparent;
	}
	.timline-block-arrow{
		border-top: 1px solid transparent;
		border-left: 1px solid transparent;
	}
	.timeline-connect{
		height: 40px;
	}
	.timeline-logo{
		background-color: #FFD705;
		text-align: center;
		border-radius: 11px;
		color: #7C5609;
	}
	.voucher-address, .voucher-goods-info{
		padding:0;
		padding-left:10px;
	}
	.list-block .item-content{
		padding-left: 10px;
	}
</style>
<div class="page-group">
    <div class="page page-current" id="page-order-detail">
	    <header class="bar bar-nav">
	    	<a class="button button-link button-nav pull-left back" href="{php echo app_url('order/order/list')}"><span class="icon icon-left"></span>返回</a>
	    	<h1 class="title">售后详情</h1>
	  	</header>
    	
		<div class="content" style="overflow-x: hidden;">
			<div id="nav" class="nav">
			    <p class="nav-wrap">
			        <span class="j-nav-item j-nav-status nav-item nav-choose">售后进度</span>
			        <span class="j-nav-item j-nav-detail nav-item ">订单详情</span>
			        <label class="j-nav-bottomline nav-bottomline"></label>
			    </p>
			</div>
			<div id="order-status">
			    <div class="timeline">
				{if (empty($serves))}
		            <div class="timeline-item">
		                <span class="timeline-logo  icon icon-card"></span>
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title open-popup" id="qrcode" oid="{$order['orderno']}" data-popup=".popup-qrcode">点击申请售后</p>
		                </div>
		            </div>
					{else}
					<div class="timeline-item">
		                <span class="timeline-logo icon icon-card"></span>
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title">售后申请已提交<span class="timeline-time">{php echo date('m-d H:i', $serves['servicetime']);}</span></p>
		                    <p class="timeline-sub">等待客服反馈</p>
		                </div>
		            </div>
					{/if}
		            {if !empty($serves['feedtype'])}
		            <div class="timeline-connect timeline-connect-21"></div>
		            <div class="timeline-item">
		                <span class="timeline-logo icon icon-remove"></span>
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title">
							{$serves['feedtype']}
							<span class="timeline-time">{php echo date('m-d H:i', $serves['feedtime']);}</span></p>
		                    <p class="timeline-sub" style="word-wrap: break-word;">反馈意见：{$serves['servicefeedback']}<br/>
							
							</p>
							<div class="link-ding-footer"  {if !empty($serves['overtime'])}  style="height: 0px;" {else} style="position: relative ; height: 33px;"{/if}>
							<a {if !empty($serves['servicelastremark'])||!empty($serves['overtime'])}style="display:none;"{/if} style="width: 30%;
							height: 27.5px;
						    line-height: 27.5px;
						    text-align: center;
						    top: 5px;
						    font-size: 12px;
						    border-radius: 5px;
						    background-color: #6fbfd8;
						    display: block;
							color:white;
						    position: absolute;" 
						     class="open-popup">{if $serves['feedtype']=='退货'}同意处理结果{else}再次申述{/if}</a>
							<button {if $serves['feedtype']!='部分退款'||!empty($serves['servicelastremark'])||!empty($serves['overtime'])}style="display:none;"{else}class="weui_btn weui_btn_mini weui_btn_blue"; style="margin-top: 5px;color:white!important;height:27.5px;line-height:27.5px;position: absolute;right: 0px;text-align:center;font-size:12px;border-radius:5px;color:#999;"{/if} oid="{$order['orderno']}" id="part_refund">同意处理结果</button>
							
							</div>
							
		                </div>
		            </div>
		            {/if}
					
					 {if !empty($serves['servicelastremark'])}
					  <div class="timeline-connect timeline-connect-21"></div>
					<div class="timeline-item">
		              
						<span class="timeline-logo icon icon-message"></span>
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title ">再次申述<span class="timeline-time">{php echo date('m-d H:i', $serves['servicelasttime']);}</span></p>
		                    <p class="timeline-sub">{$serves['servicelastremark']}</p>
		                </div>
		            </div>
					{/if}
					{if !empty($serves['servicelastfeedback'])}
					  <div class="timeline-connect timeline-connect-21"></div>
					<div class="timeline-item">
		                <span class="timeline-logo icon icon-me"></span>
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title">再次反馈：{$serves['servicelastfeedtype']}<span class="timeline-time">{php echo date('m-d H:i', $serves['servicelastfeedtime']);}</span></p>
		                    <p class="timeline-sub">{$serves['servicelastfeedback']}</p>
		                </div>
		            </div>
					{/if}
					{if !empty($serves['overtime'])}
					  <div class="timeline-connect timeline-connect-21"></div>
					<div class="timeline-item">
						<span class="timeline-logo icon icon-check "></span>
		                <div class="timeline-block">
		                    <i class="timline-block-arrow"></i>
		                    <p class="timeline-title">售后完成<span class="timeline-time">{php echo date('m-d H:i', $serves['overtime']);}</span></p>
		                    <p class="timeline-sub"></p>
		                </div>
		            </div>
					{/if}
			    </div>
			    
			    <div class="bottombar-placeholder"></div>
			
			    
			</div>
			
			<div id="order-detail" style="display: none">
			    <div class="orderregion">
			        <a class="status-hotelname" href="#">
			            <i class="icon1-detail status-hotelname-icon"></i>
			            <label class="status-hotelname-name">{$order['merchant_name']}</label>
			            <i class="icon-arrow-right-thin status-hotelname-back"></i>
			        </a>
			    </div>
			    
			    <div class="orderregion orderregion-top">
			        <ul class="orderregion-entries">
					{if $order['g_id']>0}
			            <li class="orderregion-entry">
			                <span class="name text-overflow-ellipsis-2">{$goods['gname']}</span>
			               <!-- <span class="price">￥{php echo $goods['gprice']*$order['gnum']}</span>-->
			                <span class="price" >{if $order['is_tuan']==0}{$goods['oprice']}{elseif $order['is_tuan']==1}{$goods['gprice']}{/if}×{$order['gnum']}</span>
			            </li>
						{else}
						<?php 
								$col=pdo_fetchall("select * from ".tablename('tg_collect')." where  orderno=:orderno",array('orderno'=>$order['orderno']));
								?>
								 {loop $col $v}
								 <?php 
								$gs=pdo_fetch("select * from ".tablename('tg_goods')." where  id=:id",array('id'=>$v['sid']));
								
								?>
								<li class="orderregion-entry">
			                <span class="name text-overflow-ellipsis-2">{$gs['gname']}</span>
							 <span class="name text-overflow-ellipsis-2">规格：{$v['item']}</span>
			               <!-- <span class="price">￥{php echo $goods['gprice']*$order['gnum']}</span>-->
			                <span class="price" >{$v['oprice']}×{$v['num']}</span>
			            </li>
						
								 {/loop}
						{/if}
			        </ul>
			    </div>
			<?php 
								$refund=pdo_fetch("select * from ".tablename('tg_order_level_refund')." where  orderno=:orderno",array('orderno'=>$order['orderno']));
							$realprice=	round($order['pay_price'],2)-round($refund['refundprice'],2);
								?>
			    <div class="orderregion">
			        <ul class="orderregion-entries">
					{if $gs['selltype']==4}
					 <li class="orderregion-entry order-other-price">
			                <span class="name text-overflow-ellipsis-2">返还</span>
			                <span class="price">￥&nbsp;{$refund['refundprice']}</span>
			            </li>
						{/if}
			            <li class="orderregion-entry order-other-price">
			                <span class="name text-overflow-ellipsis-2">运费</span>
			                <span class="price">￥&nbsp;{$order['freight']}</span>
			            </li>
			            <li class="orderregion-entry order-total-price">
			                <span class="name text-overflow-ellipsis-2">合计</span>
			                <span class="price">￥&nbsp;{$realprice}</span>
			            </li>
			        </ul>
			    </div>

			    <!--门店-->
	            {if $order['is_hexiao'] != 0}
	            <div class="orderregion">
			        <h1 class="orderregion-title">
			            <i class="icon1-detail status-detail-icon"></i>
			            <label class="status-name">核销信息</label>
			        </h1>
			        <ul class="orderregion-entries-compact">
					 <li class="orderregion-entry-compact">
			                <span class="label">收货人：</span>{$order['addname']}&nbsp; {$order['mobile']}
			            </li>
					 
					 <li class="orderregion-entry-compact">
			                <span class="label">提货点：</span>{$sto['storename']}
			            </li>
			           <li class="orderregion-entry-compact">
			                <span class="label">核销员：</span>{$sal['nickname']}
			            </li>
			            <li class="orderregion-entry-compact" id="hexiaotime">
			                <span class="label">核销时间：</span>{php echo date('Y-m-d H:i:s', $order['hexiaotime']);}
			            </li>
			        </ul>
			    </div>
				<!--<div class="good_speci" onclick="showStores(this)" show="1">适用的商家信息<i class="fa fa-angle-down" style="float:right; line-height:44px; font-size:26px;"></i></div>
	  			<div>
		  			{loop $stores $stores}
			        <div class="store">
			            <div class="info">
			            <div class="ico"><i class="fa fa-university"></i></div>
			            <div class="info1">
			                <div class="inner">
			                     <div class="user">{$stores['storename']}</div>
			                     <div class="addresss">地址: {$stores['address']}</div>
			                     <div class="tel">电话: {$stores['tel']}</div>
			                 </div>
			             </div>
			             <a href="http://api.map.baidu.com/marker?location={$stores['lat']},{$stores['lng']}&amp;title={$stores['storename']}&amp;name={$stores['storename']}&amp;content={$stores['address']}&amp;output=html" class="external"><div class="ico2"><i class="fa fa-map-marker"></i></div></a>
			             <a href="tel:{$stores['tel']}" class="disable-router"><div class="ico3"><i class="fa fa-phone"></i></div></a>
			        	</div>
			        </div>
					{/loop}
		       	</div>-->
		       	{else}
		       	<div class="orderregion">
			        <h1 class="orderregion-title">
			            <i class="icon1-detail status-detail-icon"></i>
			            <label class="status-name">配送信息</label>
			        </h1>
			        <ul class="orderregion-entries-compact">
			            <li class="orderregion-entry-compact">
			                <span class="label">收货人：</span>{$order['addname']}&nbsp; {$order['mobile']}
			            </li>
			            <li class="orderregion-entry-compact">
			                <span class="label">收货地址：</span>{$order['address']}
			            </li>
			        </ul>
			    </div>
		       	{/if}
		       	
			    <div class="orderregion">
			        <h1 class="orderregion-title">
			            <i class="icon1-detail status-detail-icon"></i>
			            <label class="status-name">订单详情</label>
			        </h1>
			        <ul class="orderregion-entries-compact">
			            <li class="orderregion-entry-compact">
			                <span class="label">订单号码：</span>{$order['orderno']}
			            </li>
			            <li class="orderregion-entry-compact">
			                <span class="label">下单时间：</span>{php echo date('Y-m-d H:i:s', $order['createtime']);}
			            </li>
			            <li class="orderregion-entry-compact">
			                <span class="label">支付方式：</span>微信支付
			            </li>
			            {if $order['remark']}
			            <li class="orderregion-entry-compact">
			                <span class="label">备注：</span>{$order['remark']}
			            </li>
			            {/if}
			        </ul>
			    </div>

			    <div class="buy-again-placeholder"></div>
			    </div>
			</div>
		</div>
	</div>
</div>
<div class="popup popup-qrcode" id="div-qrcode">
  	<div class="content" style="background: #eee;">
	
    	<div class="list-block cards-list">
	      <ul>
		  
	        <li class="card" style="border-radius: .2rem;">
	          <div class="card-header"><h3 class="font-size-14">申请售后</h3></div>
	          <div class="card-content">
	            <div class="card-content-inner">
				<div class="item-content">
		            <div class="item-inner">
		              <div class="item-title label">退款原因：</div>
		              <div class="item-input">
		                <select id="servicereson" style="height: 30px;border: 1px solid #ddd;    background: url(http://ourjs.github.io/static/2015/arrow.png) no-repeat scroll 98% center transparent;">
		                 <option value="" >请选择退款原因</option>
                                <option value="不想买了" {if $serves['servicereson']=="不想买了"} selected="selected"{/if}>不想买了</option>
								<option value="商品错拍" {if $serves['servicereson']=="商品错拍"} selected="selected"{/if}>商品错拍</option>
								<option value="收到商品破损" {if $serves['servicereson']=="收到商品破损"} selected="selected"{/if}>收到商品破损</option>
								<option value="商品错发/漏发" {if $serves['servicereson']=="商品错发/漏发"} selected="selected"{/if}>商品错发/漏发</option>
								<option value="收到商品与描述不符" {if $serves['servicereson']=="收到商品与描述不符"} selected="selected"{/if}>收到商品与描述不符</option>
								<option value="商品质量问题" {if $serves['servicereson']=="商品质量问题"} selected="selected"{/if}>商品质量问题</option>
								
		                </select>
		              </div>
					  
		            </div>
					
		          </div>
			        
			        <div class="voucher-address font-size-14" >
					 <div class="item-inner">
		              <div class="item-title label">申请理由：</div>
		              <div class="item-input">
		               <textarea name="serviceremark" id="serviceremark" style="height: 40px;width:210px;" placeholder="请简单描述问题" >{$serves['serviceremark']}</textarea>
						
		              </div>
		            </div>
			        </div>
					
					<div class="voucher-address font-size-14" {if $serves['feedtype']=="退货"||empty($serves['serviceremark'])}style="display:none"{/if}>
					 <div class="item-inner">
		              <div class="item-title label">再次申诉理由：</div>
		              <div class="item-input">
		               <textarea name="servicelastremark" id="servicelastremark" style="height: 60px;width:220px;" placeholder="请简单描述问题" >{$serves['servicelastremark']}</textarea>                     
						
		              </div>
		            </div>
			        </div>
					
					<div class="item-content" {if $serves['feedtype']!="退货"}style="display:none"{/if}>
		            <div class="item-inner">
		              <div class="item-title label">快递公司：</div>
		              <div class="item-input">
		                <select id="feedbackexpress">
		                 <option value="" >请选择快递公司</option>
                                <option value="顺丰" data-name="顺丰" {if $serves['feedbackexpress']=="顺丰"} selected="selected"{/if}>顺丰</option>
									<option value="申通" data-name="申通" {if $serves['feedbackexpress']=="申通"} selected="selected"{/if}>申通</option>
									<option value="韵达快运" data-name="韵达快运" {if $serves['feedbackexpress']=="韵达快运"} selected="selected"{/if}>韵达快运</option>
									<option value="天天快递" data-name="天天快递" {if $serves['feedbackexpress']=="天天快递"} selected="selected"{/if}>天天快递</option>
									<option value="圆通速递" data-name="圆通速递" {if $serves['feedbackexpress']=="圆通速递"} selected="selected"{/if}>圆通速递</option>
									<option value="中通速递" data-name="中通速递" {if $serves['feedbackexpress']=="中通速递"} selected="selected"{/if}>中通速递</option>
									<option value="ems快递" data-name="ems快递" {if $serves['feedbackexpress']=="ems快递"} selected="selected"{/if}>ems快递</option>
									<option value="百世汇通" data-name="百世汇通" {if $serves['feedbackexpress']=="百世汇通"} selected="selected"{/if}>百世汇通</option>
									<option value="全峰快递" data-name="全峰快递" {if $serves['feedbackexpress']=="全峰快递"} selected="selected"{/if}>全峰快递</option>
									<option value="宅急送" data-name="宅急送" {if $serves['feedbackexpress']=="宅急送"} selected="selected"{/if}>宅急送</option>
									<option value="aae全球专递" data-name="aae全球专递" {if $serves['feedbackexpress']=="aae全球专递"} selected="selected"{/if}>aae全球专递</option>
									<option value="安捷快递" data-name="安捷快递" {if $serves['feedbackexpress']=="安捷快递"} selected="selected"{/if}>安捷快递</option>
									<option value="安信达快递" data-name="安信达快递" {if $serves['feedbackexpress']=="安信达快递"} selected="selected"{/if}>安信达快递</option>
									<option value="彪记快递" data-name="彪记快递" {if $serves['feedbackexpress']=="彪记快递"} selected="selected"{/if}>彪记快递</option>
									<option value="bht" data-name="bht" {if $serves['feedbackexpress']=="bht"} selected="selected"{/if}>bht</option>
									<option value="百福东方国际物流" data-name="百福东方国际物流" {if $serves['feedbackexpress']=="百福东方国际物流"} selected="selected"{/if}>百福东方国际物流</option>
									<option value="coe" data-name="中国东方（COE）" {if $serves['feedbackexpress']=="中国东方（COE）"} selected="selected"{/if}>中国东方（COE）</option>
									<option value="长宇物流" data-name="长宇物流" {if $serves['feedbackexpress']=="长宇物流"} selected="selected"{/if}>长宇物流</option>
									<option value="大田物流" data-name="大田物流" {if $serves['feedbackexpress']=="大田物流"} selected="selected"{/if}>大田物流</option>
									<option value="德邦物流" data-name="德邦物流" {if $serves['feedbackexpress']=="德邦物流"} selected="selected"{/if}>德邦物流</option>
									<option value="dhl" data-name="dhl" {if $serves['feedbackexpress']=="dhl"} selected="selected"{/if}>dhl</option>
									<option value="dpex" data-name="dpex" {if $serves['feedbackexpress']=="dpex"} selected="selected"{/if}>dpex</option>
									<option value="dsukuaidi" data-name="d速快递" {if $serves['feedbackexpress']=="d速快递"} selected="selected"{/if}>d速快递</option>
									<option value="递四方" data-name="递四方" {if $serves['feedbackexpress']=="递四方"} selected="selected"{/if}>递四方</option>
									<option value="fedex" data-name="fedex（国外）" {if $serves['feedbackexpress']=="fedex（国外）"} selected="selected"{/if}>fedex（国外）</option>
									<option value="飞康达物流" data-name="飞康达物流" {if $serves['feedbackexpress']=="飞康达物流"} selected="selected"{/if}>飞康达物流</option>
									<option value="凤凰快递" data-name="凤凰快递" {if $serves['feedbackexpress']=="凤凰快递"} selected="selected"{/if}>凤凰快递</option>
									<option value="飞快达" data-name="飞快达" {if $serves['feedbackexpress']=="飞快达"} selected="selected"{/if}>飞快达</option>
									<option value="国通快递" data-name="国通快递" {if $serves['feedbackexpress']=="国通快递"} selected="selected"{/if}>国通快递</option>									
									
		                </select>
		              </div>
					  
		            </div>
					
		          </div>
				  <div class="voucher-address font-size-14" {if $serves['feedtype']!="退货"}style="display:none"{/if}>
					 <div class="item-inner">
		              <div class="item-title label">快递单号：</div>
		              <div class="item-input">
		               <textarea name="feedbackexpresssn" id="feedbackexpresssn" style="height: 60px;width:220px;" placeholder="请添加快递单号" >{$serves['feedbackexpresssn']}</textarea>                     
						
		              </div>
		            </div>
			        </div>
					
					{if $order['g_id']>0}
			        <div class="voucher-goods-info font-size-14">
			            <p>商品名称：{$goods['gname']} </p>
						{if !empty($order['optionname'])}<p>商品规格：{$order['optionname']} </p>{/if}
						<p>数量：{$order['gnum']}</p>
				        <p>实付金额：{$order['pay_price']}元</p>
				        </div>
				    
					{else}
					
				   <?php 
								$col=pdo_fetchall("select * from ".tablename('tg_collect')." where  orderno=:orderno",array('orderno'=>$order['orderno']));
								?>
								 {loop $col $v}
								 <?php 
								$gs=pdo_fetch("select * from ".tablename('tg_goods')." where  id=:id",array('id'=>$v['sid']));
								?>
									
									 <div class="voucher-goods-info font-size-14">							
										<p style="font-weight: 600;margin-top: 10px">{$gs['gname']}</p>
										<p>{if !empty($v['item'])}规格：{$v['item']}{/if}</p>
										<p>数量：{$v['num']}</p>
										<p>单价：￥{$v['oprice']}</p>
										<hr style="margin-top: 10px;margin-bottom: 0px;"/>
									</div>
									
								 {/loop}
					{/if}
					 </div>
	          </div>
	        </li>
	      </ul>
	    </div>
	    <div class="weui_btn_area">
        	<a class="weui_btn weui_btn_warn " id="btn_serves" oid="{$order['orderno']}">提交</a>
			<a class="weui_btn weui_btn_warn close-popup" id="close-p" style="display:none">关闭</a>
    	</div>
  	</div>
</div>
<script>

{if (empty($serves))}
window.onload = function () {

	var popupQrcode = document.getElementsByClassName("popup popup-qrcode")[0];

	  popupQrcode.classList.add("modal-in");
	  popupQrcode.style.display = 'block';
	
}
{/if}
$(document).on('click','#qrcode',function(){
$("#div-qrcode").show();

	});
$(document).on('click','#part_refund',function(){
$(this).attr('disabled','disabled');

var orderno = $(this).attr('oid');
var feedbackfee = $("#feedbackfee").val();
$.post("{php echo app_url('order/serves/part_refund')}",{orderno:orderno,feedbackfee:feedbackfee},function(d){
					if(d.status == 1){					
					   $.toast(d.result);
						location.reload();
					}else{
						$.toast(d.result);
					}
				},"json");

	});
$(document).on('click','#btn_serves',function(){
	var orderno = $(this).attr('oid');
	var servicereson = $("#servicereson").val();
	var serviceremark = $("#serviceremark").val();
	var servicelastremark = $("#servicelastremark").val();
	var feedbackexpress = $("#feedbackexpress").val();
	var feedbackexpresssn = $("#feedbackexpresssn").val();
	if(servicereson=='')
	{
		$.toast('请选择售后原因');
		return;
	}
	if(serviceremark=='')
	{
		$.toast('请简单描述问题');
		return;
	}
	
	{if $serves['feedtype']=="退货"}
	if(feedbackexpress=='')
	{
		$.toast('请选择快递公司');
		return;
	}
	if(feedbackexpresssn=='')
	{
		$.toast('请添加快递单号');
		return;
	}
	{/if}
	$.post("{php echo app_url('order/serves/check')}",{orderno:orderno,servicereson:servicereson,serviceremark:serviceremark,servicelastremark:servicelastremark,feedbackexpress:feedbackexpress,feedbackexpresssn:feedbackexpresssn},function(d){
					if(d.status == 1){
					$("#close-p").click();
					    $.toast('申请成功，请等待客服审核！');
					    location.reload();
					}else{
						$.toast(d.result);
					}
				},"json");
	       
	
});
$(".j-nav-status").bind('click', function() {
		$('.j-nav-status').addClass('nav-choose');
		$('.j-nav-detail').removeClass('nav-choose');
		$('.j-nav-bottomline').removeClass('nav-bottomlineright').addClass('nav-bottomline');
		$('#order-status').show();
		$('#order-detail').hide();
	});
	$(".j-nav-detail").bind('click', function() {
		$('.j-nav-detail').addClass('nav-choose');
		$('.j-nav-status').removeClass('nav-choose');
		$('.j-nav-bottomline').removeClass('nav-bottomline').addClass('nav-bottomlineright');
		$('#order-status').hide();
		$('#order-detail').show();
	});
</script>
{php include wl_template('common/footer');}}